import request from '@/utils/request'
import { axiosPostJson, axiosPostFrom } from "@/utils/service";
import qs from "qs";

export function login(data) {
  const form = {
    username: data.username,
    password: data.password,
    grant_type: 'password',
    scope: 'read'
  }
  
  // return request({
  //   url: "/auth-server/oauth/token",
  //   headers: {
  //     "Content-Type": "application/x-www-form-urlencoded",
  //     // Authorization: "Basic dGVzdF9jbGllbnQ6dGVzdF9zZWNyZXQ="
  //   },
  //   method: "post",
  //   params: form
  // });
  return axiosPostFrom("/auth-server/oauth/token", form, {
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    }
  });
}

// 获取接口权限
export function getInfo(token) {
  return request({
    url: '/organization/user',
    method: 'get',
    params: { uniqueId: 'admin' }
  })
}

export function logout() {
  return Promise.resolve({
    code: "000000",
    mesg: "成功",
    time: new Date(),
  })
}
